package com.zzy.util.tzzy.util.weather;

import com.zzy.util.tzzy.util.UtilHttp;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * 天气预报的工具类
 */
public class UtilWeather {

    public static void main(String args[]) {
        String cityName = "沈丘";//要查询天气的城市
        Map<String, String> cityCodeMap2 = UtilCityWeatherCode.getCityCodeMap2();
        String cityCode = cityCodeMap2.get(cityName);//   "";//获取code
        System.out.println(cityCode);
        if (StringUtils.isNotBlank(cityCode)) {//模拟Http请求
            try {// 101181410
                String apiurl = "http://t.weather.sojson.com/api/weather/city/" + cityCode;
                //String host = "t.weather.sojson.com";
                //String res = UtilHttp.get(apiurl, host, "80");
                String res = UtilHttp.sendGet(apiurl, "");
                //乱码处理
                System.out.println(res);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }




}
